package java_objects.this_pointer;

public class Student {

	String name;
	int marks;
	char grade;
	
	Student (int marks){
		
		this.marks = marks;
		
		if (marks >= 90){
			grade = 'A';
		}else if (marks >= 80) {
			grade = 'B';
		}else if (marks >= 70) {
			grade = 'C';
		}else {
			grade = 'F';
		}
	}
	
	Student (String name, int marks){
		
		this(marks);
		//this(name); // error: call to this must be first statement in constructor
		
		this.name = name;
		
	}
	
	public static void main(String[] args) {
		Student s1 = new Student("Robert", 85);
		s1.print();
		
		Student s2 = new Student("Ajay", 92);
		s2.print();
		
		Student s3 = new Student("Max", 72);
		s3.print();
		
		Student s4 = new Student("Nasir", 61);
		s4.print();

	}
	
	void print (){
		System.out.println("Name = " + name + " , Marks = " + marks + " , Grade = " + grade);
	}

}
